package ah.szxy;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author caohaiyang
 * @create 2020-09-18 下午 05:03
 */
@SpringBootApplication
@RestController
public class DubboConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(DubboConsumerApplication.class, args);
    }

    @Reference  //dubbo的包
    private EchoService echoService;

    @GetMapping("/rpc/{msg}")
    public ResponseEntity<String> rpc(@PathVariable("msg") String msg){
        String echo = echoService.echo(msg);
        return ResponseEntity.ok("远程调用成功, 结果为: "+echo);
    }
}